<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>个人中心 - 百货购物平台</title>
    <link rel="stylesheet" href="layui-v2.9.20/layui/css/layui.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
        }

        body {
            background-color: #fafafa;
        }

        /* 顶部导航栏 - 全新粉色风格 */
        .header-container {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: linear-gradient(135deg, #ffecef 0%, #fff0f3 100%);
            padding: 0 40px;
            box-shadow: 0 4px 20px rgba(255, 156, 176, 0.15);
            position: relative;
            z-index: 1000;
            height: 70px;
            border-bottom: 1px solid #ffdde4;
        }

        .logo {
            display: flex;
            align-items: center;
            font-size: 28px;
            font-weight: 800;
            color: #ff4d7a;
            text-shadow: 1px 1px 3px rgba(255, 77, 122, 0.2);
        }

        .logo i {
            margin-right: 10px;
            font-size: 32px;
        }

        .nav-menu {
            display: flex;
            list-style: none;
            height: 100%;
        }

        .nav-menu li {
            display: flex;
            align-items: center;
            position: relative;
            padding: 0 20px;
            cursor: pointer;
            transition: all 0.3s ease;
            height: 100%;
        }

        .nav-menu li a {
            text-decoration: none;
            color: #ff4d7a;
            font-size: 16px;
            font-weight: 600;
            display: flex;
            align-items: center;
            height: 100%;
            padding: 0 5px;
            transition: all 0.3s;
        }

        .nav-menu li a i {
            margin-right: 8px;
            font-size: 18px;
        }

        .nav-menu li:hover {
            background: rgba(255, 255, 255, 0.5);
        }

        .nav-menu li.active {
            background: linear-gradient(to bottom, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.4));
        }

        .nav-menu li.active::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 3px;
            background: linear-gradient(to right, #ff8da1, #ff4d7a);
            border-radius: 3px 3px 0 0;
        }

        .nav-menu li.active a {
            color: #e6004c;
        }

        /* 搜索框样式 - 已优化 */
        .search-container {
            background-color: #fff;
            padding: 0;
            position: sticky;
            top: 0;
            z-index: 999;
            box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
            border-bottom: 1px solid #f0f0f0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 90px;
        }

        .search-box {
            width: 700px;
            margin: 0 auto;
            display: flex;
            border: 2px solid #ff4d7a;
            border-radius: 8px;
            overflow: hidden;
            box-shadow: 0 5px 15px rgba(255, 77, 122, 0.2);
            height: 52px;
        }

        .search-select {
            padding: 0 15px;
            background: #fff;
            border: none;
            border-right: 1px solid #eee;
            outline: none;
            color: #ff4d7a;
            font-weight: 500;
            width: 130px;
            appearance: none;
            background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ff4d7a' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 10px center;
            background-size: 16px;
            cursor: pointer;
        }

        .search-select:focus {
            background-color: #fff9fb;
        }

        .search-input-container {
            flex: 1;
            display: flex;
            align-items: center;
            position: relative;
        }

        .search-input {
            flex: 1;
            border: none;
            padding: 0 20px 0 45px;
            font-size: 16px;
            outline: none;
            color: #333;
            height: 100%;
        }

        .search-icon {
            position: absolute;
            left: 15px;
            color: #999;
            font-size: 18px;
        }

        .search-button {
            background: linear-gradient(135deg, #ff4d7a 0%, #ff8da1 100%);
            color: white;
            border: none;
            padding: 0 35px;
            font-size: 17px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .search-button:hover {
            background: linear-gradient(135deg, #ff3366 0%, #ff7799 100%);
        }

        /* 内容容器 */
        .content-container {
            max-width: 1200px;
            margin: 40px auto;
            padding: 0 20px;
        }

        .section-title {
            position: relative;
            font-size: 26px;
            margin: 35px 0 25px;
            padding-left: 15px;
            color: #ff4d7a;
            font-weight: 700;
        }

        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 8px;
            bottom: 8px;
            width: 5px;
            background: linear-gradient(to bottom, #ff8da1, #ff4d7a);
            border-radius: 5px;
        }

        /* 个人中心样式 */
        .profile-container {
            display: flex;
            flex-wrap: wrap;
            gap: 20px;
            margin-bottom: 30px;
        }

        .profile-sidebar {
            flex: 1;
            min-width: 250px;
            background: #fff;
            border-radius: 12px;
            box-shadow: 0 5px 25px rgba(255, 141, 161, 0.15);
            padding: 25px;
        }

        .profile-content {
            flex: 3;
            min-width: 300px;
            background: #fff;
            border-radius: 12px;
            box-shadow: 0 5px 25px rgba(255, 141, 161, 0.15);
            padding: 25px;
        }

        .user-info {
            display: flex;
            flex-direction: column;
            align-items: center;
            text-align: center;
            padding-bottom: 20px;
            border-bottom: 1px solid #f0f0f0;
            margin-bottom: 20px;
        }

        .user-avatar {
            width: 100px;
            height: 100px;
            border-radius: 50%;
            object-fit: cover;
            border: 3px solid #ffdde4;
            margin-bottom: 15px;
        }

        .user-name {
            font-size: 22px;
            font-weight: 700;
            color: #ff4d7a;
            margin-bottom: 5px;
        }

        .user-level {
            background: linear-gradient(135deg, #ff8da1 0%, #ff4d7a 100%);
            color: white;
            padding: 3px 15px;
            border-radius: 20px;
            font-size: 12px;
            margin-bottom: 15px;
        }

        .user-balance {
            display: flex;
            justify-content: space-around;
            width: 100%;
            margin-top: 15px;
        }

        .balance-item {
            text-align: center;
        }

        .balance-value {
            font-size: 18px;
            font-weight: 700;
            color: #ff4d7a;
        }

        .balance-label {
            font-size: 14px;
            color: #888;
        }

        .profile-menu {
            list-style: none;
        }

        .profile-menu li {
            margin-bottom: 15px;
        }

        .profile-menu a {
            display: flex;
            align-items: center;
            padding: 12px 15px;
            border-radius: 8px;
            color: #333;
            text-decoration: none;
            transition: all 0.3s;
        }

        .profile-menu a i {
            width: 25px;
            font-size: 18px;
            color: #ff4d7a;
            margin-right: 10px;
        }

        .profile-menu a:hover,
        .profile-menu a.active {
            background: #fff9fb;
            color: #ff4d7a;
            transform: translateX(5px);
        }

        .profile-section {
            margin-bottom: 30px;
        }

        .profile-section-title {
            font-size: 20px;
            color: #ff4d7a;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 1px solid #f0f0f0;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: 600;
            color: #555;
        }

        .form-control {
            width: 100%;
            padding: 12px 15px;
            border: 1px solid #e0e0e0;
            border-radius: 8px;
            font-size: 15px;
            transition: all 0.3s;
        }

        .form-control:focus {
            border-color: #ff8da1;
            outline: none;
            box-shadow: 0 0 0 3px rgba(255, 141, 161, 0.2);
        }

        .btn {
            padding: 12px 25px;
            border: none;
            border-radius: 8px;
            font-size: 15px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s;
        }

        .btn-primary {
            background: linear-gradient(135deg, #ff4d7a 0%, #ff8da1 100%);
            color: white;
        }

        .btn-primary:hover {
            background: linear-gradient(135deg, #ff3366 0%, #ff7799 100%);
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(255, 77, 122, 0.3);
        }

        .btn-outline {
            background: #fff;
            border: 1px solid #ff4d7a;
            color: #ff4d7a;
        }

        .btn-outline:hover {
            background: #fff9fb;
        }

        .address-card {
            background: #fff9fb;
            border: 1px solid #ffdde4;
            border-radius: 8px;
            padding: 15px;
            margin-bottom: 15px;
            position: relative;
        }

        .address-header {
            display: flex;
            justify-content: space-between;
            margin-bottom: 10px;
        }

        .address-name {
            font-weight: 600;
        }

        .default-tag {
            background: #ff4d7a;
            color: white;
            padding: 2px 10px;
            border-radius: 4px;
            font-size: 12px;
        }

        .address-actions {
            position: absolute;
            bottom: 15px;
            right: 15px;
        }

        .address-actions button {
            padding: 5px 10px;
            margin-left: 5px;
            font-size: 13px;
        }

        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }

        .stat-card {
            background: #fff9fb;
            border-radius: 10px;
            padding: 20px;
            text-align: center;
            border: 1px solid #ffdde4;
            transition: all 0.3s;
        }

        .stat-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(255, 141, 161, 0.1);
        }

        .stat-icon {
            font-size: 30px;
            color: #ff4d7a;
            margin-bottom: 15px;
        }

        .stat-value {
            font-size: 28px;
            font-weight: 700;
            color: #ff4d7a;
            margin-bottom: 5px;
        }

        .stat-label {
            font-size: 16px;
            color: #888;
        }

        /* 页脚样式 */
        .footer {
            background: linear-gradient(135deg, #343a40 0%, #23272b 100%);
            color: #fff;
            padding: 50px 0 30px;
            margin-top: 70px;
        }

        .footer-content {
            max-width: 1200px;
            margin: 0 auto;
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 35px;
            padding: 0 20px;
        }

        .footer-column h3 {
            font-size: 20px;
            margin-bottom: 22px;
            padding-bottom: 12px;
            border-bottom: 2px solid #ff4d7a;
            color: #fff;
        }

        .footer-column ul {
            list-style: none;
        }

        .footer-column li {
            margin-bottom: 14px;
        }

        .footer-column a {
            color: #ddd;
            text-decoration: none;
            transition: all 0.3s;
            display: flex;
            align-items: center;
        }

        .footer-column a i {
            margin-right: 8px;
            color: #ff8da1;
        }

        .footer-column a:hover {
            color: #ff8da1;
            transform: translateX(5px);
        }

        .copyright {
            text-align: center;
            padding-top: 40px;
            margin-top: 40px;
            border-top: 1px solid #444;
            color: #aaa;
            font-size: 14px;
            max-width: 1200px;
            margin: 40px auto 0;
        }

        /* 响应式调整 */
        @media (max-width: 992px) {
            .footer-content {
                grid-template-columns: repeat(2, 1fr);
            }
        }

        @media (max-width: 768px) {
            .header-container {
                flex-direction: column;
                height: auto;
                padding: 15px;
            }

            .nav-menu {
                width: 100%;
                margin-top: 15px;
                justify-content: center;
            }

            .nav-menu li {
                padding: 10px 15px;
            }

            .search-box {
                width: 90%;
            }

            .profile-container {
                flex-direction: column;
            }
        }

        @media (max-width: 576px) {
            .nav-menu {
                flex-wrap: wrap;
            }

            .nav-menu li {
                padding: 8px 12px;
            }

            .search-box {
                flex-direction: column;
                border-radius: 15px;
                height: auto;
            }

            .search-select {
                width: 100%;
                padding: 12px 20px;
                border-right: none;
                border-bottom: 1px solid #eee;
                height: 50px;
            }

            .search-input-container {
                width: 100%;
            }

            .search-input {
                padding: 12px 20px 12px 45px;
                height: 50px;
            }

            .search-icon {
                left: 20px;
            }

            .search-button {
                padding: 15px;
                height: 50px;
            }

            .footer-content {
                grid-template-columns: 1fr;
            }

            .user-balance {
                flex-direction: column;
                gap: 10px;
            }
        }
    </style>
</head>

<body>
    <!-- 顶部导航栏 -->
    <div class="header-container">
        <div class="logo">
            <i class="fas fa-shopping-bag"></i>
            <span>百货购物平台</span>
        </div>
        <ul class="nav-menu">
            <li>
                <a href="index.html"><i class="fas fa-home"></i> 首页</a>
            </li>
            <li>
                <a href="cart item.html"><i class="fas fa-shopping-cart"></i> 购物车</a>
            </li>
            <li>
                <a href="checkout.html"><i class="fas fa-cash-register"></i> 结算</a>
            </li>
            <li>
                <a href="order.html"><i class="fas fa-file-invoice"></i> 我的订单</a>
            </li>
            <li class="active">
                <a href="person_center.html"><i class="fas fa-user-circle"></i> 个人中心</a>
            </li>
            <li>
                <a href="customer_service.html"><i class="fas fa-headset"></i> 官方客服</a>
            </li>
        </ul>
    </div>

    <!-- 搜索框 -->
    <div class="search-container">
        <div class="search-box">
            <select class="search-select">
                <option value="" disabled selected>全部商品</option>
                <option value="AAA">女装</option>
                <option value="BBB">男装</option>
                <option value="CCC">美妆</option>
                <option value="DDD">数码</option>
                <option value="EEE">食品</option>
            </select>
            <div class="search-input-container">
                <i class="fas fa-search search-icon"></i>
                <input type="text" class="search-input" placeholder="输入搜索关键字...">
            </div>
            <button class="search-button">搜索</button>
        </div>
    </div>

    <!-- 内容容器 -->
    <div class="content-container">
        <h2 class="section-title">个人中心</h2>

        <div class="profile-container">
            <!-- 左侧菜单 -->
            <div class="profile-sidebar">
                <div class="user-info">
                    <img src="https://images.unsplash.com/photo-1611003228941-98852ba62227?q=80&w=400&auto=format&fit=crop"
                        alt="用户头像" class="user-avatar">
                    <div class="user-name">果小锅</div>
                    <div class="user-level">钻石会员</div>
                    <div class="user-balance">
                        <div class="balance-item">
                            <div class="balance-value">¥3,280</div>
                            <div class="balance-label">账户余额</div>
                        </div>
                        <div class="balance-item">
                            <div class="balance-value">2560</div>
                            <div class="balance-label">积分</div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 右侧内容 -->
            <div class="profile-content">
                <!-- 个人信息部分 -->
                <div class="profile-section">
                    <h3 class="profile-section-title">个人信息</h3>

                    <div class="form-group">
                        <label>用户名</label>
                        <input type="text" class="form-control" id="userNameInput">
                    </div>
                    <div class="form-group">
                        <label>手机号码</label>
                        <input type="text" class="form-control" id="userPhoneInput">
                    </div>
                    <div class="form-group">
                        <label>电子邮箱</label>
                        <input type="email" class="form-control" id="userEmailInput">
                    </div>
                    <div class="form-group">
                        <label>性别</label>
                        <select class="form-control" id="userGenderSelect">
                            <option value="女">女</option>
                            <option value="男">男</option>
                        </select>
                    </div>
  

                    <button class="btn btn-primary">保存信息</button>
                </div>

                <!-- 收货地址部分 -->
                <!-- <div class="profile-section">
                <h3 class="profile-section-title">收货地址 <button class="btn btn-outline" style="float: right;"><i class="fas fa-plus"></i> 添加地址</button></h3>

                <div class="address-card">
                    <div class="address-header">
                        <div class="address-name">张小雨</div>
                        <div class="default-tag">默认地址</div>
                    </div>
                    <div class="address-details">
                        <p>手机号码：13800138000</p>
                        <p>地址：北京市海淀区中关村大街1号科技大厦A座1203室</p>
                    </div>
                    <div class="address-actions">
                        <button class="btn btn-outline">编辑</button>
                        <button class="btn btn-outline">删除</button>
                    </div>
                </div>

                <div class="address-card">
                    <div class="address-header">
                        <div class="address-name">张小雨</div>
                    </div>
                    <div class="address-details">
                        <p>手机号码：13900139000</p>
                        <p>地址：上海市浦东新区张江高科技园区亮秀路112号Y1座</p>
                    </div>
                    <div class="address-actions">
                        <button class="btn btn-outline">编辑</button>
                        <button class="btn btn-outline">删除</button>
                    </div>
                </div>
            </div> -->
            </div>
        </div>
    </div>


    <script src="layui-v2.9.20/layui/layui.js"></script>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        const user = JSON.parse(localStorage.getItem('user'));
        // 初始化Layui模块
        layui.use(['element'], function () {
            var element = layui.element;

            // 设置导航菜单激活状态
            document.querySelectorAll('.nav-menu li').forEach(item => {
                item.addEventListener('click', function () {
                    document.querySelectorAll('.nav-menu li').forEach(i => {
                        i.classList.remove('active');
                    });
                    this.classList.add('active');
                });
            });

            // 设置个人中心菜单激活状态
            document.querySelectorAll('.profile-menu a').forEach(item => {
                item.addEventListener('click', function (e) {
                    e.preventDefault();
                    document.querySelectorAll('.profile-menu a').forEach(i => {
                        i.classList.remove('active');
                    });
                    this.classList.add('active');
                });
            });

            // 地址操作按钮
            document.querySelectorAll('.address-actions button').forEach(button => {
                button.addEventListener('click', function () {
                    const action = this.textContent;
                    const addressCard = this.closest('.address-card');

                    if (action === '删除') {
                        if (confirm('确定要删除这个地址吗？')) {
                            addressCard.remove();
                        }
                    } else if (action === '编辑') {
                        alert('编辑地址功能');
                    }
                });
            });
        });
        function getBackendBaseUrl() {
            // 根据当前环境确定后端URL
            if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
                return 'http://localhost:8080';
            }
            // 生产环境使用相同域名
            return window.location.origin;
        }
       
        function getUserInfoAndRender() {
            $.ajax({
                url: getBackendBaseUrl() + "/user/info",
                method: 'GET',
                data: {
                    userId: user.userId  
                },
                xhrFields: {
                    withCredentials: true
                },
                success: function (data) {
                        renderUserInfo(data.data || data); 
                },
                error: function (xhr, status, error) {
                    alert('网络错误，请稍后重试');
                }
            });
        }
        function renderUserInfo(user) {
            $('#userNameInput').val(user.userName || '');
            $('#userPhoneInput').val(user.phone || '');
            $('#userEmailInput').val(user.email || '');
            $('#userGenderSelect').val(user.gender || '女');
        }
        document.addEventListener('DOMContentLoaded', function () {
            getUserInfoAndRender();
        });
    </script>
</body>

</html>